import {createRouter, createWebHistory} from 'vue-router'
import LoginView from "../views/user/LoginView.vue";

export const router = createRouter({
    history: createWebHistory(import.meta.env.baseURL),
    routes: [
        {
            path: '/',
            component: () => import('../views/HomeView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/:id',
            component: () => import('../components/ContentComponent.vue')
        },
        {
            path: '/login',
            component: LoginView,
            meta: {
                admin: false
            }
        },
        {
            path: '/map',
            component: () => import('../views/map/DistributionView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/identify',
            component: () => import('../views/identify/IdentifyView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/medicine',
            component: () => import('../views/medicine/MedicineView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/medicine/:id',
            component: () => import('../views/medicine/DetailInfoView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/forum',
            component: () => import('../views/forum/ForumView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/forum/:id',
            component: () => import('../views/forum/DetailInfoView.vue'),
            meta: {
                admin: false
            }
        },
        {
            path: '/forum/new',
            component: () => import('../views/forum/EditPostView.vue'),
            meta: {
                withoutHeader: true,
                admin: false
            }
        },
        {
            path: '/admin/login',
            component: () => import('../views/admin/login/LoginView.vue'),
            meta: {
                admin: true
            }
        },
        {
            path: '/welcome',
            component: () => import('../views/admin/home/index.vue'),
            children: [
                {
                    path: '/welcome/home',
                    component: () => import('../views/admin/home/WelcomeView.vue'),
                    meta: {
                        admin: true
                    }
                },
                {
                    path: '/welcome/medicine',
                    component: () => import('../views/admin/home/MedicineView.vue'),
                    meta: {
                        admin: true
                    }
                },
                {
                    path: '/welcome/prescription',
                    component: () => import('../views/admin/home/PrescriptionView.vue'),
                    meta: {
                        admin: true
                    }
                },
                {
                    path: '/welcome/post',
                    component: () => import('../views/admin/home/PostView.vue'),
                    meta: {
                        admin: true
                    }
                },
                {
                    path: '/welcome/user',
                    component: () => import('../views/admin/home/UserView.vue'),
                    meta: {
                        admin: true
                    }
                }
            ],
            meta: {
                admin: true
            }
        }
    ]
})
